package c2.cross.business.guildwar.core;

import c2.cross.business.base.CrossSubModule;
import c2.cross.business.guildwar.GuildWarModule;
import c2.cross.business.guildwar.common.GuildWarStatus;
import cate.game.pvp.guildwar.data.GWInnerMsg;
import cate.game.pvp.guildwar.data.base.GWMatchGroup;
import cate.game.pvp.guildwar.data.base.GuildWarBase;
import cate.game.pvp.guildwar.data.msg.GWBaseInnerResp;
import cate.game.pvp.guildwar.data.msg.GWTopGuildRwdReq;
import cate.game.pvp.guildwar.data.rank.GWGuildRank;
import easy.java.dev.note.NoteClass;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
@NoteClass("公会战-消息分发模块")
public class GWCrossMessagingModule extends CrossSubModule<GuildWarModule> {

	/**
	 * 同步公会战基础数据
	 * @param srvId
	 * @param status
	 */
	public void sendBackBase(int srvId, GuildWarStatus status, List<GWGuildRank> rankList)  {
		try {
			useRpcSend().fireAndForgetGameTemplate(GWInnerMsg.GAME_CONNECT_BACK,
					srvId,
					GWBaseInnerResp.of(status.base, status.match.matchList,rankList));
		} catch (Exception e) {
			log.error("", e);
		}
	}

	public void noticeBase(GuildWarBase base, List<GWMatchGroup> matchList, List<GWGuildRank> rankList) {
		try {
			useRpcSend().fireAndForgetGameInCrossTemplate(GWInnerMsg.CROSS_BASE,
					parent.code(),
					GWBaseInnerResp.of(base, matchList, rankList));
		} catch (Exception e) {
			log.error("", e);
		}
	}

	public void settleGuildRwd(int srvId,String guildUid){
		try {
			useRpcSend().fireAndForgetGameTemplate(GWInnerMsg.CROSS_TOP_RWD,
					srvId, GWTopGuildRwdReq.of(guildUid));
		} catch (Exception e) {
			log.error("", e);
		}
	}
}
